package com.example.a90419.audio;

public class MessageHandler implements XFAudioRecord.LoadStreamListener {

    private StreamListener listener;

    public MessageHandler(StreamListener listener) {
        this.listener = listener;
    }


    @Override
    public void load(byte[] stream, int offset, int len) {

        if (null != listener) {
//            for (int k = 0; k < offset; k++) {
//                int m = 0;
//                for (int i = offset * len; i < (offset + 1) * len; i++) {
//                    if (i < stream.length) {
//                        byte[] temp = new byte[len];
//                        temp[m] = stream[i];
//                        listener.send(temp);
//                        m++;
//                    }
//                }
//            }
            listener.send(stream);
        }
    }


    public interface StreamListener {
        void send(byte[] buff);
    }


}
